package com.tianquan.miracledemo.test;/**
 * @author starsea
 * @date 2024-09-29 上午11:57
 */

import com.tianquan.miracle.annotation.Component;
import com.tianquan.miracle.aware.BeanFactoryAware;
import com.tianquan.miracle.aware.BeanNameAware;
import com.tianquan.miracle.core.BeanFactory;
import com.tianquan.miracle.postprocessor.BeanPostProcessor;
import com.tianquan.miracle.postprocessor.InitializingBean;

/**
 * @BelongsProject: uploaddemo
 * @BelongsPackage: com.tianquan.miracle.test
 * @Author: tianquan
 * @CreateTime: 2024-09-29  11:57
 * @Description: 测试
 * @Version: 1.0
 */
@Component
public class B implements BeanPostProcessor, InitializingBean, BeanFactoryAware, BeanNameAware {

    // @Autowired
    private A a;

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) {
        System.out.println("postProcess-Before-Initialization");
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) {
        System.out.println("postProcess-After-Initialization");
        return bean;
    }

    @Override
    public void afterPropertiesSet(){
        System.out.println("afterPropertiesSet-B");
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) {
        System.out.println("setBeanFactory-B");
        this.a = beanFactory.getBean(A.class);
    }

    @Override
    public void setBeanName(String name) {
        System.out.println("name = " + name);
    }
}
